﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Globalization;

namespace Gvs.Controls.Numeric
{

	public class IntBox : NumericBoxBase<int>
	{

		protected override bool CanParse(string text)
		{
			int buf;
			return int.TryParse(
			    this.Text,
			    NumberStyles.Any,
			    CultureInfo.CurrentCulture,
			    out buf);
		}

		protected override int? DoParse(string text)
		{
			int buf;
			if (int.TryParse(
			    this.Text,
			    NumberStyles.Any,
			    CultureInfo.CurrentCulture,
			    out buf))
			{
				return buf;
			}
			return null;
		}

		protected override string ToText(int value)
		{
			return value.ToString(this.FormatString, CultureInfo.CurrentCulture);
		}


		#region IControlExpend 成员



		//public object GetValue()
		//{
		//        return this.Value;
		//}

		//public void SetValue(object obj)
		//{
		//        this.Value = obj as int?;			
		//}

		#endregion
	}
}
